package cn.iocoder.yudao.module.system.repository.mybatis.dao.sensitiveword;

import cn.iocoder.yudao.common.pojo.PageResult;
import cn.iocoder.yudao.core.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.core.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.repository.mybatis.domain.sensitiveword.SensitiveWord;
import cn.iocoder.yudao.module.system.vo.sensitiveword.SensitiveWordExportReqVO;
import cn.iocoder.yudao.module.system.vo.sensitiveword.SensitiveWordPageReqVO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 敏感词 Mapper
 *
 * @author 永不言败
 */
@Mapper
public interface SensitiveWordMapper extends BaseMapperX<SensitiveWord> {

    default PageResult<SensitiveWord> selectPage(SensitiveWordPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SensitiveWord>()
                .likeIfPresent(SensitiveWord::getName, reqVO.getName())
                .likeIfPresent(SensitiveWord::getTags, reqVO.getTag())
                .eqIfPresent(SensitiveWord::getStatus, reqVO.getStatus())
                .betweenIfPresent(SensitiveWord::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(SensitiveWord::getId));
    }

    default List<SensitiveWord> selectList(SensitiveWordExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<SensitiveWord>()
                .likeIfPresent(SensitiveWord::getName, reqVO.getName())
                .likeIfPresent(SensitiveWord::getTags, reqVO.getTag())
                .eqIfPresent(SensitiveWord::getStatus, reqVO.getStatus())
                .betweenIfPresent(SensitiveWord::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(SensitiveWord::getId));
    }

    default SensitiveWord selectByName(String name) {
        return selectOne(SensitiveWord::getName, name);
    }

}
